package com.frinder.seata.order.web;

import com.frinder.seata.data.base.Result;
import com.frinder.seata.data.domain.model.TbOrder;
import com.frinder.seata.order.service.BizOrderService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName BizOrderController
 * @Description 订单服务
 * @Author frinder
 * @Date 2020/8/18 15:42
 * @Verion 1.0
 */
@RestController
@RequestMapping("/biz/order")
public class BizOrderController {

    @Resource
    private BizOrderService bizOrderService;

    @ApiOperation("客户下单")
    @PostMapping("/create")
    public Result create(@RequestBody TbOrder order,
                         @RequestParam(defaultValue = "false") boolean timeout,
                         @RequestParam(defaultValue = "false") boolean circle
    ) {
        bizOrderService.create(order, timeout, circle);
        return Result.defSuccess();
    }

    @ApiOperation("完成下单")
    @PostMapping("/completed")
    public Result completed(@RequestParam long orderId) {
        bizOrderService.completed(orderId);
        return Result.defSuccess();
    }

}
